﻿@{
    Layout = "../Shared/_InnerPage.cshtml";
}
@model XoohooViewModelItem<IEnumerable<RoleBasic>>
@section TitleContent{
    @Html.SiteTitle("系统管理", "用户管理", "角色管理", "角色列表")
}
@section HeadCustom{
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $(".delete>a").click(function () {
                if (!confirm("警告！删除该角色后，将无法恢复！\n确定要删除该角色？")) { return false; }
            });
        });
    </script>
}
@section NavigationContent
{
    当前位置：用户管理 &gt;&gt; 角色管理 &gt;&gt; 角色列表
}
@{
    IEnumerable<RoleBasic> roles = Model.Item;
    Html.BeginRouteForm("Admin.Membership.User.RoleList", FormMethod.Post, new { @id = "RoleSearchForm", @name = "RoleSearchForm" });
    if (!roles.IsNullOrEmpty())
    {
        int maxDisplayOrder = roles.Max(v => v.DisplayOrder);
        WriteLiteral(Html.Grid(roles).Columns(column =>
        {
            column.For(item => item.DisplayOrder).Named("顺序").HeaderAttributes(@class => "titNum").Attributes(@class => "conNum");
            column.For(item => item.RoleName).Named("角色名称").HeaderAttributes(@class => "titOth").Attributes(@class => "conOth");
            column.For(item => Html.ActionLink("上移", "RoleMove", new { RoleID = item.RoleID, Target = MovingTarget.Up })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => p.DisplayOrder > 2);
            column.For(item => Html.ActionLink("下移", "RoleMove", new { RoleID = item.RoleID, Target = MovingTarget.Down })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => p.DisplayOrder != maxDisplayOrder && p.DisplayOrder != 1);
#if DEBUG
    column.For(item => Html.ActionLink("编辑", "RoleAddOrEdit", new { RoleID = item.RoleID })).Encode(false).Attributes(@class => "conCtr");
#else
            column.For(item => Html.ActionLink("编辑", "RoleAddOrEdit", new { RoleID = item.RoleID })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => !p.IsSystem);
#endif
            column.For(item => Html.ActionLink("删除", "RoleRemove", new { RoleID = item.RoleID })).Encode(false).Attributes(@class => "conCtr delete").CellCondition(p => !p.IsSystem);
            column.For(item => item.IsSystem ? "系统" : String.Empty).Encode(false).Attributes(@class => "conCtr");
        })
            //表格属性
.Attributes(@class => "tbl")
            //表头行属性
    .HeaderRowAttributes(new Hash(@class => "rowhead"))
            //列表行属性
.RowAttributes(data => new Hash(@class => "{0}".FormatWith(data.IsAlternate ? "rowodd" : ""))));
    }
}
@{Html.EndForm();}
